﻿using System;
using System.Runtime.Serialization;
using System.Xml.Serialization;

namespace Cubicle.Core.Processors
{
    [DataContract]
    [Serializable]
    //[KnownType(typeof(object[]))]
    //[KnownType(typeof(object[][]))]
    public class InstructionParameter
    {

        [XmlAttribute("row")]
        public int Row;

        [XmlAttribute("column")]
        public int Column;

        [DataMember]
        [XmlAttribute("handle")]
        public string Handle;

        [XmlAttribute("key")]
        [DataMember]
        public string Key;

        [DataMember]
        [XmlIgnore]
        public object Value;

        [XmlAttribute("value")]
        public string StrValue
        {
            get
            {
                return Value == null ? null : Value.ToString();
            }
            set
            {
                Value = value;
            }
        }

        [XmlAttribute("type")]
        public string ValueType;

        public InstructionParameter() { }

        public InstructionParameter(int row, int column, string handle)
        {
            Column = column;
            Row = row;
            Handle = handle;
        }

        public InstructionParameter(string key, int row, int column)
        {
            Column = column;
            Row = row;
            Key = key;
        }

        public InstructionParameter(int row, int column, object value)
        {
            Column = column;
            Row = row;
            Value = value;
        }
    }
}